package priv.pront.code.mati.national.practice;

import java.io.*;
import java.util.*;

/**
 * @Author: Pronting
 * @Description: TODO
 * @DateTime: 2023/12/2 13:55
 **/
public class P2032_扫描 {


    static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        st.nextToken();
        int n = (int) st.nval;
        st.nextToken();
        int k = (int) st.nval;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            st.nextToken();
            arr[i] = (int) st.nval;
        }

        Deque<Integer> deque = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            while (!deque.isEmpty() && deque.peekLast() < arr[i]) {
                deque.pollLast();
            }
            deque.offerLast(arr[i]);

            if (i >= k - 1) {
                if (i - k >= 0 && deque.peekFirst() == arr[i - k]) {
                    deque.pollFirst();
                }
                out.println(deque.peekFirst());
                out.flush();
            }
        }
    }
}
